/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hiddenwebsearch;

import java.util.ArrayList;
import java.util.List;

/**
 * Category Node Structure
 * @author Star
 */
public class CNode {
    //Initial category node
    CNode Parent =null;
    //Children of the node
    List<CNode> Children = new ArrayList<CNode>();
    //Keyword list for a category
    List<String> Keyword = new ArrayList<String>();
    String value ="";
    int tc = -1;
    double ts = 0;
    //initial category of the node
    public CNode(String v)
    {
        this.value=v;
    }
   
    //Merge two keyword list, eliminent the duplicate words
    public List<String> Merge (List<String> sqlist)
    {
        List<String> newqlist = this.Keyword;
        for(int i=0; i<sqlist.size(); i++)
        {
            if (newqlist.contains(sqlist.get(i))==false)
            newqlist.add(sqlist.get(i));    
        }
        return newqlist;
    }
    
    // add a new node to children list
    public void add(CNode child)
    {
        this.Children.add(child);
        child.Parent=this;
    }
    
    //Generate a defualt tree
    public static CNode getDefault()
    {
        CNode root= new CNode("Root");
        CNode com = new CNode("Computers");
        CNode hea = new CNode("Health");
        CNode spo = new CNode("Sports");
        CNode hdw = new CNode("Hardware");
        CNode pro = new CNode("Programming");
        CNode dis = new CNode("Diseases");
        CNode fit = new CNode("Fitness");
        CNode sco = new CNode("Soccer");
        CNode bsk = new CNode("Basketball");
        root.add(com);
        root.add(hea);
        root.add(spo);
        com.add(hdw);
        com.add(pro);
        hea.add(fit);
        hea.add(dis);
        spo.add(sco);
        spo.add(bsk);
        
        return root;
    }
    
}
